<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/view/console/common/css.html"){}	%>

 <title></title>
 </head>
 <body>
 <div class="zq-form">
 <form name="wnAppUser_form"  id="wnAppUser_form" class="form-horizontal" style="margin-bottom: 70px;">
   <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">用户昵称</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="nickName" id="nickName" class="form-control" check-type="required" value='${wnAppUser.nickName!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">电话号码</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="phoneNumber" id="phoneNumber" class="form-control" check-type="required" value='${wnAppUser.phoneNumber!}' >
 </div>
  </div>
 <div class="form-group" style="display: none" >
 <label class="col-sm-2 col-xs-2 control-label">用户密码</label>
 <div class="col-sm-6 col-xs-6">
 <input  type="text"  name="password" id="password" class="form-control"  value='${wnAppUser.password!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">是否删除</label>
 <div class="col-sm-6 col-xs-6">
 <div class="radio">
 <label><input checked='checked' auto_name='wnAppUser_isDel' type="radio"  name="isDel" value="0"/>否</label>
 <label><input  auto_name='wnAppUser_isDel' type="radio"  name="isDel" value="1"/>是</label>
  
 </div>
 </div>
  </div>
 <div class="form-group">
 <label class="control-label col-sm-2 col-xs-2">渠道来源</label>
 <div class="col-sm-6 col-xs-6">
 	<select class="form-control" id="sourceChannel"
 		name="sourceChannel" check-type="required">
 	<option selected='selected' value="app">app注册</option>
 	<option  value="console">后台录入</option>
 </select>
 </div>
 </div>
 <div class="form-group" >
 <label class="col-sm-2 col-xs-2 control-label">用户类型</label>
 <div class="col-sm-6 col-xs-6">
 <div class="radio">
 <label><input checked='checked' auto_name='wnAppUser_userTyep' type="radio"  name="userType" value="1"/>app用户</label>
 <label><input  auto_name='wnAppUser_userTyep' type="radio"  name="userType" value="2"/>农机用户</label>
  
 </div>
 </div>
  </div>
 
   <input type='hidden' name='id' id='id' value='${wnAppUser.id!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>
 </form>
  <nav class="navbar navbar-default navbar-fixed-bottom" style="text-align: right">
    <a href="#" class="btn btn-success" style="margin:10px"  onclick='saveZqForm()'>保存 </a>
  </nav>
 </div>
 <% include("/view/console/common/js.html"){} 	%>
 <script type='text/javascript'  >

  layui.use(['layer','laydate'], function(){

  });
  $(function($) {
   /*开启表单验证*/
   $("#wnAppUser_form").validation();
   $('input[auto_name="wnAppUser_isDel"]').each(function(){
    if('${wnAppUser.isDel!}'==this.value){
     $(this).attr('checked','checked');
    }
   });
   $("#sourceChannel").val("${wnAppUser.sourceChannel!}");
   if('${wnAppUser.sourceChannel!}'==''){
    $("#sourceChannel").val('app');
   }
   $('input[auto_name="wnAppUser_userTyep"]').each(function(){
    if('${wnAppUser.userType!}'==this.value){
     $(this).attr('checked','checked');
    }
   });

  });
  /*保存*/
  function saveZqForm(){
   if ($("#wnAppUser_form").valid() == false) {
    return false;
   }
   var formObject=new Object();
   formObject.nickName=$('#nickName').val()==''?null:$('#nickName').val();
   formObject.phoneNumber=$('#phoneNumber').val()==''?null:$('#phoneNumber').val();
   formObject.password=$('#password').val()==''?null:$('#password').val();
   formObject.isDel=($('input[name="isDel"]:checked').val()==''?null:$('input[name="isDel"]:checked').val());
   formObject.sourceChannel=$('#sourceChannel').val()==''?null:$('#sourceChannel').val();
   formObject.userType=($('input[name="userType"]:checked').val()==''?null:$('input[name="userType"]:checked').val());
   formObject.id=$('#id').val()==''?null:$('#id').val();

   var formObjectJson = JSON.stringify(formObject);
   $.post("/console/wn_app_user/save",
           {
            formObjectJson :formObjectJson,
            common_token :$("#common_token").val()
           }, function(data) {
            layer.alert(data.message, {skin: 'layui-layer-molv',closeBtn: 0 }, function(){
             parent.$("#wnAppUser").bootstrapTable("refresh");
             parent.layer.closeAll();
            });

           });
  }

 </script>
 </body>
